package cn.shuangbofu;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by shuangbofu on 2020-04-17 19:15
 */
public class Test {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 5; i++) {
            int finalI = i;
            Thread taskDispatcher = new Thread(() -> {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                    } finally {

                    }
                    System.out.println(finalI);
                    System.out.println();
                }
            });
            taskDispatcher.setName("test-" + i);
            executorService.submit(taskDispatcher);
        }
        executorService.shutdown();
    }
}
